package cuckoo.ioc;

import cuckoo.ioc.container.ScanBeanContainer;
import cuckoo.ioc.container.config.Internal;
import cuckoo.log.Logger;
import cuckoo.log.LoggerFactory;

public class CuckooContainer extends ScanBeanContainer {
	private Logger logger = LoggerFactory.getLogger(CuckooContainer.class);

	public CuckooContainer(String packageName) {
		super(packageName);
	}

	public void start() {
		long start = System.currentTimeMillis();

		registerIndependent(Internal.CONTAINER, this);

		try {
			logger.info("Cuckoo Container starting.");

			doScan();

			logger.info("Cuckoo Container started successfully. cost time : {}ms", (System.currentTimeMillis() - start));
		} catch (Exception e) {
			logger.error("error occured while Cuckoo Container starting ", e);
			destroy();
		}
	}
}
